﻿using System.Collections.Generic;
using System.Linq;

namespace SS4U.Library.ConfigurationClasses
{
    public class SearchDefinitionCollection: List<SearchDefinition>
    {
        public SearchDefinition GetDefault()
        {
            var sd = (from x in this where x.IsDefault select x).FirstOrDefault();
            return sd ?? (Count > 0 ? this[0] : null);
        }

        public SearchDefinition GetByName(string name)
        {
            var sd = (from x in this where x.Name == name select x).FirstOrDefault();
            return sd ?? null;
        }

        public SearchDefinition GetById(int id)
        {
            var sd = (from x in this where x.Id == id select x).FirstOrDefault();
            return sd ?? null;
        }
    }
}
